
var Widget = Widget || {};

Widget.Config = function() {
	
	var KEY_AUTO_CHALLENGE_TIME = 'config.autoChallengeTime';
	var KEY_AUTO_HIDE = 'config.autoHide';
	
	this.autoChallengeTime = function(autoChallengeTime) {
		if (typeof(autoChallengeTime) != 'undefined') {
			_set(KEY_AUTO_CHALLENGE_TIME, autoChallengeTime.toString());
		} else {
			return parseInt(_get(KEY_AUTO_CHALLENGE_TIME, 1));
		}
	}
	
	this.autoHide = function(autoHide) {
		if (typeof(autoHide) != 'undefined') {
			_set(KEY_AUTO_HIDE, autoHide.toString());
		} else {
			return _get(KEY_AUTO_HIDE, true) == 'true';
		}
	}
	
	function _set(key, value) {
		widget.setPreferenceForKey(value, key);
	}
	
	function _get(key, defaultValue) {
		var val = widget.preferenceForKey(key);
		return (val == null || val.length == 0) ? defaultValue : val; 
	}
	
	function _init() {
		Widget.Utils.initializeSingleton(Widget.Config, this);
	}
	
	// Initializer
	_init();

}

// Static methods & methods
Widget.Config.instance = function() {
	
	return Widget.Utils.singletonInstance(Widget.Config, true);	

}


